package com.github.m6d21.sso.common.util;

import java.util.Map;

/**
 *<p>
 *MapUtil
 *</p>
 *
 * @author liuyang
 * @date 2018-12-07 Fri 12:58:35
 * @since 1.0.0
 */
public class MapUtil {

    private MapUtil() {
    }

    public static boolean isEmpty(Map map) {
        return map == null || map.size() == 0;
    }

    public static boolean isNotEmpty(Map map) {
        return map != null && map.size() > 0;
    }

    /**
     * 获取map的值
     *
     * @param <K> type of key
     * @param <V> type of value
     * @param key key
     * @param map map
     * @return the value
     */
    public static <K, V> V valueOf(K key, Map<K, V> map) {
        return isNotEmpty(map) ? map.get(key) : null;
    }

}
